//
//  SetPayPasswordVController.m
//  Experss
//
//  Created by 嗯，大葱 on 17/8/9.
//  Copyright © 2017年 嗯，大葱. All rights reserved.
//

#import "SetPayPasswordVController.h"
#import "LXCInputPasswordView.h"
#import "FixPassTwoVController.h"

@interface SetPayPasswordVController ()<LXCInputPasswordViewDelegate>
{
    NSString *inputOnePassword;
}

@property (nonatomic, strong)LXCInputPasswordView *passView;



@end

@implementation SetPayPasswordVController
-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    _sureBtn.userInteractionEnabled = NO;
    _sureBtn.selected = NO;
    _passView = [LXCInputPasswordView inputPasswordViewWithY:115+20];
    _passView.delegate = self;
    
    [self.view addSubview:_passView];
    
}

#pragma mark 密码输入框的代理事件
- (void)inputPasswordViewDelegate:(LXCInputPasswordView *)inputPasswordView inputEndWithPassword:(NSString *)inputEndWithPassword {
    
    inputOnePassword = inputEndWithPassword;
    NSLog(@"---%@",inputEndWithPassword);
    _sureBtn.selected = YES;
    _sureBtn.userInteractionEnabled = YES;
    
}

//小于6位不能确认按钮不能点击
- (void)inputPasswordXiaoYuSix {
    _sureBtn.selected = NO;
    _sureBtn.userInteractionEnabled = NO;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self configureNaBar];
}


//超市和配送段共用设置提现或者支付密码界面
- (void)configureNaBar {
    if ([_typeStr isEqualToString:@"支付密码"]) {
        self.navigationItem.title = @"设置支付密码";
        _titlLB.text= @"请设置支付密码";
        
    }if ([_typeStr isEqualToString:@"提现密码"]) {
         _titlLB.text= @"请设置提现密码";
        self.navigationItem.title = @"设置提现密码";
    }
    
    //设置导航栏按钮的边距
    UIButton * rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    rightBtn.frame= CGRectMake(0, 0, 60, 30);
    [rightBtn setImage:[UIImage imageNamed:@"all_fanhui2"] forState:(UIControlStateNormal)];
    [rightBtn addTarget:self action:@selector(handleBackAxtion) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem *btn_left = [[UIBarButtonItem alloc] initWithCustomView:rightBtn];
    UIBarButtonItem *negativeSpacerleft = [[UIBarButtonItem alloc]   initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace   target:nil action:nil];
    /**
     width为负数时，相当于btn向右移动width数值个像素，由于按钮本身和  边界间距为5pix，所以width设为-5时，间距正好调整为0；width为正数 时，正好相反，相当于往左移动width数值个像素
     */
    negativeSpacerleft.width = -20;
    self.navigationItem.leftBarButtonItems = [NSArray arrayWithObjects:negativeSpacerleft, btn_left, nil];
    
    
    
}


- (void)handleBackAxtion {
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)nextStepAction:(UIButton *)sender {
    FixPassTwoVController *se = [[FixPassTwoVController alloc] init];
    se.type2 = _typeStr;
    se.inputOnePassword = inputOnePassword;
    se.phoneCodeStr= _codeStr;
    se.moblePhoneStr = _phoneStr;
    
    [self.navigationController pushViewController:se animated:YES];
}



@end
